from django.contrib import admin

# Register your models here.
from polls.models import Subject, Teacher, User


class SubjectAdmin(admin.ModelAdmin):
    list_display = ('no', 'name', 'infro', 'is_hot')  # 将要展示的各项名称
    list_display_links = ('no', 'name')  # 创建的软连接
    search_fields = ('name',)  # 创建克搜索字段
    ordering = ('no',)  # 按指定字段排序 （注意此处为元祖，切勿忘记后面的逗号）


admin.site.register(Subject, SubjectAdmin)


class TeacherAdmin(admin.ModelAdmin):
    list_display = ('no', 'name', 'gender', 'hero', 'intro', 'good_count', 'bad_count', 'subject')
    list_display_links = ('no', 'name')
    search_fields = ('name', 'gender')
    ordering = ('no',)


admin.site.register(Teacher, TeacherAdmin)


class UserAdmin(admin.ModelAdmin):
    list_display = ('username', 'password', 'tel', 'reg_date', 'last_visit')
    list_display_links = ('username','tel')
    ordering = ('userid',)

admin.site.register(User,  UserAdmin)
